{% extends 'admin/base.html' %}

{% block content %}
    <div class="w-full px-6 py-8">
        <div class="mb-6 flex justify-between items-center">
            <h1 class="text-2xl font-semibold">浏览记录</h1>
        </div>

        <div class="bg-white !rounded-lg shadow">
            <table class="w-full">
                <thead>
                <tr class="text-left border-b border-gray-200">
                    <th class="px-6 py-4 text-sm font-medium text-gray-500 text-center">#</th>
                    <th class="px-6 py-4 text-sm font-medium text-gray-500 text-center">用户名</th>
                    <th class="px-6 py-4 text-sm font-medium text-gray-500 text-center">推荐电影</th>
                    <th class="px-6 py-4 text-sm font-medium text-gray-500 text-center">创建时间</th>
                </tr>
                </thead>
                <tbody>
                {% for his in pagination.current_items %}
                    <tr class="border-b border-gray-200">
                        <td class="px-6 py-4 text-center" style="color: #4e7fc7">{{ loop.index }}</td>
                        <td class="px-6 py-4 text-center">{{ his.username }}</td>
                        <td class="px-6 py-4 text-center truncate max-w-[160px]" title="{{ his.movie_name }}">{{ his.movie_name }}</td>
                        <td class="px-6 py-4 text-center">{{ his.created_at }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
            {% with endpoint='admin.recommend_result', url_params={} %}
                {% include 'admin/components/page.html' with context %}
            {% endwith %}
        </div>
    </div>
{% endblock %}

{% block scripts %}
    {{ super() }}
    <script>
        const page_num = document.getElementById('page_num').innerText;
        sessionStorage.setItem('recommendPage', page_num);
    </script>
{% endblock %}